package gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.List;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;

public class Buttonlist extends JPanel {
	List<String> filenames;
	private Graphwindow graph;

	public Buttonlist(List<File> files, Graphwindow graph) {
		this.graph = graph;
		
		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		for (File f: files) {
			add(new GraphButton(f));
		}
	}
	
	class GraphButton extends JButton implements ActionListener {
		File file;
		
		public GraphButton(File f) {
			super(f.getName());
			file = f;
			
			this.addActionListener(this);
		}

		@Override
		public void actionPerformed(ActionEvent arg0) {
			graph.setEpisode(file);
		}
	}
}
